﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace Skyttespill
{
    class SetHighscore
    {
        ArrayList high = new ArrayList();
        string score;

        public void Setscore(string _score)
        {
            string path = @"High.txt";
            score = _score;

            StreamReader readhigh = new StreamReader(path);

            string lines = string.Empty;

            while ((lines = readhigh.ReadLine()) != null)
            {
                high.Add(lines);
            }
            readhigh.Close();

            int count = high.Count;
            if (count > 9)
            {
                high.Add(score);
                high.Sort();
                high.Reverse();
                high.RemoveAt(10);
            }
            else
            {
                high.Add(score);
                high.Sort();
                high.Reverse();
            }

            StreamWriter writehigh = new StreamWriter(path, false);
            foreach (object s in high)
                writehigh.WriteLine(s.ToString());
            writehigh.Close();
        }
    
    
    }
}
